package com.wp.service.impl;

import com.wp.dao.SysUserDao;
import com.wp.entity.SysUser;
import com.wp.service.SysUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {

    @Resource  // 注解注入属性
    private SysUserDao sysUserDao;

    @Override
    public SysUser login( String account, String password) {
        return sysUserDao.login(account,password);
    }

    @Override
    public List<SysUser> findUserByPage(Integer pageIndex, Integer pageSize,String queryRealName,Integer queryRoleId) throws Exception {
        //根据页码获取偏移量（pageIndex-1）*pageSize
        Integer from = (pageIndex-1)*pageSize;
        List<SysUser> list = sysUserDao.queryUserListByPage(from,pageSize,queryRealName,queryRoleId);
        return list;
    }

    @Override
    public Integer findUserTotalCount(String queryRealName, Integer queryRoleId) {
        return sysUserDao.queryUserTotalCount(queryRealName,queryRoleId);
    }

    @Override
    public int toAdd(SysUser sysUser) {
        return sysUserDao.toAdd(sysUser);
    }

    @Override
    public SysUser getAccountExist(String account) {
        return sysUserDao.getAccountExist(account);
    }

    @Override
    public SysUser findById(Integer id) {
        return sysUserDao.findById(id);
    }

    @Override
    public int del(Integer id) {
        return sysUserDao.del(id);
    }

    @Override
    public int upd(SysUser sysUser) {
        return sysUserDao.upd(sysUser);
    }

    @Override
    public int queryPassword(Integer id, String password) {
        return sysUserDao.queryPassword(id,password);
    }

    @Override
    public int savePassword(String password,Integer id) {
        return sysUserDao.savePassword(password,id);
    }
}
